package com.eclink.asset.consume.controller;

import com.eclink.asset.consume.domain.dao.ConsumeAuditConfigNode;
import com.eclink.asset.consume.service.ConsumeAuditConfigNodeService;
import com.eclink.asset.domain.AuditUser;
import com.ruoyi.common.core.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 耗材审批配置节点Controller
 *
 * @author chenshixian
 * @date 2024-08-24
 */
@Api("耗材审批配置节点接口列表")
@RestController
@RequestMapping("/consume/auditConfigNode")
public class ConsumeAuditConfigNodeController extends BaseController {

    @Resource
    private ConsumeAuditConfigNodeService service;

    @ApiOperation("查询审核人员")
    @GetMapping("/listUser")
    public ResponseEntity<List<AuditUser>> listUser() {
        List<AuditUser> list = service.listUser();
        return ResponseEntity.ok(list);
    }

    @ApiOperation("查询所有")
    @GetMapping("/listAll")
    public ResponseEntity<List<ConsumeAuditConfigNode>> listAll(String configId) {
        List<ConsumeAuditConfigNode> list = service.selectListAll(configId);
        return ResponseEntity.ok(list);
    }


    @ApiOperation("新增")
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody ConsumeAuditConfigNode auditConfigNode) {
        return ResponseEntity.ok(service.insert(auditConfigNode));
    }

    @ApiOperation("修改")
    @PutMapping
    public ResponseEntity<Object> edit(@RequestBody List<ConsumeAuditConfigNode> list) {
        service.update(list);
        return ResponseEntity.ok(1);
    }

    @ApiOperation("删除")
	@DeleteMapping("/{id}")
    public ResponseEntity<Integer> remove(@PathVariable Long id) {
        return ResponseEntity.ok(service.deleteById(id));
    }
}
